
/*
*赛事用户相关接口
*/
//封装请求
import request from "@/utils/request.js";
//基础配置
import APP from '@/config/app.js'
//活动人口
const Qualifying = APP.Qualifying;
//您的域名
const HTTP_REQUEST_URL = APP.HTTP_REQUEST_URL;
//活动人口
const Welfare = APP.Welfare;


//实例化
const url = request.request;

//用户注册
 function getOpenid(data ={}) {
	data['m'] = 'public_welfare';//模型
	data['c'] = 'users';//控制器
	data['op'] = 'getOpenid';//方法
	return  url.post(Welfare, data);
}

//首页
 function getUserapi(data ={}) {
	data['m'] = 'qualifying';//模型
	data['c'] = 'user';//控制器
	data['op'] = 'getUser';//方法
	return  url.post(Qualifying, data);
}
//获取用户赛事次数
 function getUserAccountapi(data ={}) {
	data['m'] = 'qualifying';//模型
	data['c'] = 'user';//控制器
	data['op'] = 'getUserAccount';//方法
	return  url.post(Qualifying, data);
}
//用户分享接口
 function getUserShareapi(data ={}) {
	data['m'] = 'qualifying';//模型
	data['c'] = 'user';//控制器
	data['op'] = 'getUserShare';//方法
	return  url.post(Qualifying, data);
}


//插入用户
 function inserUserapi(data ={},filePath) {
	data['m'] = 'qualifying';//模型
	data['c'] = 'user';//控制器
	data['op'] = 'inserUser';//方法
	if(filePath){
	uni.uploadFile({
		url: HTTP_REQUEST_URL+Qualifying, 
		filePath: filePath,
		name: 'file',
		formData: data,
		success: (uploadFileRes) => {
			return uploadFileRes.data;
		}
	});
	}else{
		return  url.post(Qualifying, data);
	}
}
//用户打榜记录
 function getUserProjectAchievementapi(data ={}) {
	data['m'] = 'qualifying';//模型
	data['c'] = 'user';//控制器
	data['op'] = 'getUserProjectAchievement';//方法
	return  url.post(Qualifying, data);
}
//插入用户
 function updataUserapi(data ={},filePath) {
	data['m'] = 'qualifying';//模型
	data['c'] = 'user';//控制器
	data['op'] = 'updataUser';//方法
	if(filePath){
   //图片上传
	uni.uploadFile({
		url: HTTP_REQUEST_URL+Qualifying, 
		filePath: filePath,
		name: 'file',
		formData: data,
		success: (uploadFileRes) => {
			return uploadFileRes.data;
		}
	});
	}else{
		return  url.post(Qualifying, data);
	}
}
 //解析微信小程序获得的手机号
  function getUserPhone(data ={}) {
 	data['m'] = 'public_welfare';//模型
 	data['c'] = 'users';//控制器
 	data['op'] = 'getUserPhone';//方法
 	return  url.post(Welfare, data);
 }
 //获取seesionkey
  function getJscoden(data ={}) {
 	data['m'] = 'public_welfare';//模型
 	data['c'] = 'users';//控制器
 	data['op'] = 'getOpenid';//方法
 	return  url.post(Welfare, data);
 }
export default {
	getUserapi,
	inserUserapi,
	updataUserapi,
	getUserAccountapi,
	getOpenid,
	getUserShareapi,
	getUserProjectAchievementapi,
	getUserPhone,
	getJscoden,
}